package com.gemme.gemme.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;

public class SexView extends RelativeLayout {
    private Context context;

    public SexView(Context context) {
        this(context,null);
    }

    public SexView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public SexView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    ImageView iv_head;
    ImageView iv;
    boolean isSelect = false;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.item_sex,this);

        iv_head = findViewById(R.id.iv_head);
        iv = findViewById(R.id.iv);
        changeState();

        /*iv_head.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                isSelect = !isSelect;
                changeState();

            }
        });*/
    }


    public View getClickView(){
        return iv_head;
    }

    public SexView setImage(int imageResouce){
        iv_head.setBackgroundResource(imageResouce);
        return this;
    }

    public boolean getSelect(){
        return isSelect;
    }

    public void setSelect(boolean select){
        isSelect = select;
        changeState();
    }
    public void changeState(){
        if(isSelect){
            iv.setBackgroundResource(R.drawable.select);
        }else{
            iv.setBackgroundResource(R.drawable.unselect);
        }
    }


}
